﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using TagLib;
using File = TagLib.File;

namespace GDFlacTool.Common
{
    [Serializable]
    public class TrackShn : Track
    {
        #region Fields.

        private readonly bool _isEmpty;
        private readonly string _trackFormat = string.Empty;
        private readonly bool _isSupportedFormat;

        #endregion

        #region Constructors.

        public TrackShn() { }

        public TrackShn(string path)
        {
            base.FullPath = path;

            _trackFormat = "shn";

            _isSupportedFormat = false;

            ReadFileInfo();

            _isEmpty = false;
        }

        #endregion

        #region Override Methods.

        public override string TrackFormat
        {
            get { return _trackFormat; }
        }

        public override bool IsSupportedTag
        {
            get { return _isSupportedFormat; }
        }

        public override bool IsEmpty
        {
            get { return _isEmpty; }
        }

        public override bool RenameTrack(MaskHelperCollection masks, TrackRename trackRename)
        {
            return false;
        }

        #endregion

        #region Private Methods.

        //private bool CreateTagLibFile(string path)
        //{
        //    return false;
        //}

        private void ReadFileInfo()
        {
            //_xiphComment = (XiphComment)_taglibfile.GetTag(TagTypes.Xiph);

            var fileInfo = new FileInfo(base.FullPath);

            //Create a file path
            FilePath = string.Format("{0}{1}", Path.GetDirectoryName(FullPath), Path.DirectorySeparatorChar);

            //Read the file name
            FileName = Path.GetFileName(FullPath);

            //Read bitrate
            BitRate = 0;

            //Read duration
           
            Time = string.Format("{0:0#}:{1:0#}:{2:0#}", 0, 0, 0);

            TimeTicks = 0;

            //Read the file size
            Size = fileInfo.Length;

            //Read the sample rate
            SampleRate = "0";

            //Read the bps
            BitsPerSample = "0";

            //Read channels
            Channels = 0;

            //Read the encoder info
            base.Encoder = "";
        }

        #endregion
    }
}
